package com.franklin.java.action.sql;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.util.NlsActions;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.util.Optional;

/**
 * 快速查找SQL 使用的地方
 * @author Franklin
 * @since 2021/9/7 11:24
 */
public class FindSqlUsagesAction extends AbstractSqlAction {
    public FindSqlUsagesAction(PsiElement sqlActionElement) {
        super(
            "Find sql usages",
            "Easier to find the sql where you used",
            AllIcons.Actions.Find,
            sqlActionElement
        );
    }

    @Override
    public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
        Optional.ofNullable(getMapperMethod())
            .ifPresent(this::startFindUsages);
    }
}
